package com.colin.app.activity.view.coordinator;

import android.view.MotionEvent;
import android.view.View;

import com.colin.app.R;
import com.colin.app.activity.view.ViewContract;
import com.colin.app.activity.view.ViewPresenterImpl;
import com.colin.app.app.AppActivity;
import com.colin.app.bean.DemoBean;

public class CustomCoordinatorActivity extends AppActivity implements ViewContract.ViewView {
    private ViewContract.ViewPresenter mViewPresenter = null;

    @Override
    protected void onDestroy() {
        if (null != mViewPresenter) {
            mViewPresenter.destroy();
            mViewPresenter = null;
        }
        super.onDestroy();
    }

    @Override
    public void initPresenter() {
        DemoBean demoBean = getIntent().getExtras().getParcelable("clazz");
        mViewPresenter = new ViewPresenterImpl(this, this, demoBean);
    }

    @Override
    public int initViewLayoutID() {
        return R.layout.activity_custom_coordinator;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        mViewPresenter.setData();
    }

    @Override
    public void initListener() {
        findViewById(R.id.button_dependency).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_MOVE:
                        v.setX(event.getRawX() - v.getWidth() / 2);
                        v.setY(event.getRawY() - v.getHeight() / 2);
                        break;
                }
                return false;
            }
        });
    }
}
